package 代码记录.指定公司代码练习记录.备战快手;

/**
 * @author zx
 * @create 2023-05-13 11:59
 */
public class 二维数组中的查找_Offer_04 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix.length == 0) return false;
        int row = 0, col = matrix[0].length - 1;
        while(row < matrix.length && col >= 0){
            if(matrix[row][col] == target){
                return true;
            }else if(matrix[row][col] > target){
                col--;
            }else if(matrix[row][col] < target){
                row++;
            }
        }
        return false;
    }
}
